package com.dh.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;

public class CollectionDemo02 {
    public static void main(String[] args) {
        Collection collection = new ArrayList();
//        collection.add(new Dog("老李"));
//        System.out.println(collection.size());//1
//        collection.remove(new Dog("老李"));
//        System.out.println(collection.size());//0

        Dog dog = new Dog("老李");
        collection.add(dog);
        collection.remove(dog);
        System.out.println(collection.size());
    }
}


class Dog {
    private String name;

    public Dog(String name) {
        this.name = name;
    }

//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Dog dog = (Dog) o;
//        return Objects.equals(name, dog.name);
//    }


}
